{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.112878Z",
     "start_time": "2025-11-05T06:23:11.108036Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from sklearn.metrics import confusion_matrix"
   ],
   "outputs": [],
   "execution_count": 23
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.135784Z",
     "start_time": "2025-11-05T06:23:11.131534Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 定义类别标签\n",
    "labels = ['猫', '狗']\n",
    "# 定义数据（预测值和真实值）\n",
    "y_true = [\"猫\", \"猫\", \"猫\", \"猫\", \"猫\", \"猫\", \"狗\", \"狗\", \"狗\", \"狗\"]\n",
    "y_pred = [\"猫\", \"猫\", \"狗\", \"猫\", \"猫\", \"猫\", \"猫\", \"猫\", \"狗\", \"狗\"]"
   ],
   "id": "7976167333668f7f",
   "outputs": [],
   "execution_count": 24
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.155864Z",
     "start_time": "2025-11-05T06:23:11.147692Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 得到混淆矩阵\n",
    "matrix = confusion_matrix(y_true, y_pred, labels=labels)\n",
    "print(matrix)"
   ],
   "id": "2b0240022558b4f5",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[5 1]\n",
      " [2 2]]\n"
     ]
    }
   ],
   "execution_count": 25
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.187130Z",
     "start_time": "2025-11-05T06:23:11.177398Z"
    }
   },
   "cell_type": "code",
   "source": "print(pd.DataFrame(matrix, index=labels, columns=labels))",
   "id": "aedd4c01d4790734",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   猫  狗\n",
      "猫  5  1\n",
      "狗  2  2\n"
     ]
    }
   ],
   "execution_count": 26
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.463994Z",
     "start_time": "2025-11-05T06:23:11.230987Z"
    }
   },
   "cell_type": "code",
   "source": "sns.heatmap(matrix, annot=True, fmt=\"d\", cmap=\"Greens\")",
   "id": "4426e5a510c5ee6f",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAGiCAYAAACRRH6CAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjcsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvTLEjVAAAAAlwSFlzAAAPYQAAD2EBqD+naQAAIgRJREFUeJzt3Q1UVWW6wPHnoAEqSaFCM+JkohIpEUF+3HSZNn50sy9Na8qPMQvQgeaOOfh5w8YaSpvyFupAlkvTW45lFuW1xsnFnZmaUBTNUBMsiyEVrmky8qHCXe+7rudy9jngxjnI4bz/n2uv495ns/f2rOh9zvM8796O+vr6egEAAEYJaO0LAAAAlx8BAAAABiIAAADAQAQAAAAYiAAAAAADEQAAAGAgAgAAAAxEAAAAgIEIAAAAMBABAAAAPuKPf/yjREdHuyyPP/64x30/+eQTGTt2rMTFxcmUKVPk22+/bda5HNwKGAAA37By5UrZs2ePLF682LktKChIOnfu7LJfWVmZ3HnnnZKWliZDhw6V5cuXS0lJibz33nvicDhsnau9168eAABcEjWI9+3bV7p169bkfhs3bpT+/fvLI488otczMzPl1ltvlfz8fBk4cKCtc1ECAADAhwKAnj17XnQ/lSVITEx0rnfo0EH69esnhYWFts9FBgAAgBZUW1url4YCAwP10pB6OO9XX30lf/nLXyQ7O1vOnz8vY8aM0T0A1n3Ly8slPDzcZVuXLl3k6NGjbS8AcIyMbO1LAHxO1dYvW/s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gIAIAAAAMRAAAAICBCAAAADAQAQAAAAYiAAAAwEAEAAAAiHn+F+92eoQg4G/3AAAAAElFTkSuQmCC"
     },
     "metadata": {},
     "output_type": "display_data",
     "jetTransient": {
      "display_id": null
     }
    }
   ],
   "execution_count": 27
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.490238Z",
     "start_time": "2025-11-05T06:23:11.484705Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import accuracy_score\n",
    "\n",
    "accuracy = accuracy_score(y_true, y_pred)\n",
    "# 准确率\n",
    "print(accuracy)"
   ],
   "id": "e2ff37a911357f89",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7\n"
     ]
    }
   ],
   "execution_count": 28
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.531325Z",
     "start_time": "2025-11-05T06:23:11.523803Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import precision_score\n",
    "\n",
    "precision = precision_score(y_true, y_pred, pos_label='猫')\n",
    "# 精确率\n",
    "print(precision)"
   ],
   "id": "eb8aac8e67d96325",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7142857142857143\n"
     ]
    }
   ],
   "execution_count": 29
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:23:11.562298Z",
     "start_time": "2025-11-05T06:23:11.552092Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import recall_score\n",
    "\n",
    "# 召回率\n",
    "recall = recall_score(y_true, y_pred, pos_label='猫')\n",
    "print(recall)"
   ],
   "id": "9f1e57cabb45b135",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.8333333333333334\n"
     ]
    }
   ],
   "execution_count": 30
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:27:34.120788Z",
     "start_time": "2025-11-05T06:27:34.111069Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import f1_score\n",
    "\n",
    "# F1-score\n",
    "f1 = f1_score(y_true, y_pred, pos_label='猫')\n",
    "print(f1)"
   ],
   "id": "f6f22427be0069e5",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7692307692307693\n"
     ]
    }
   ],
   "execution_count": 31
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-11-05T06:31:15.597060Z",
     "start_time": "2025-11-05T06:31:15.586441Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import classification_report\n",
    "\n",
    "report = classification_report(y_true, y_pred, labels=labels,target_names= None)\n",
    "print(report)"
   ],
   "id": "dafbf17e4f968d98",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           猫       0.71      0.83      0.77         6\n",
      "           狗       0.67      0.50      0.57         4\n",
      "\n",
      "    accuracy                           0.70        10\n",
      "   macro avg       0.69      0.67      0.67        10\n",
      "weighted avg       0.70      0.70      0.69        10\n",
      "\n"
     ]
    }
   ],
   "execution_count": 40
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
